package cn.shiwei.org.service.impl;

import cn.shiwei.basic.query.BaseQuery;
import cn.shiwei.basic.service.impl.BaseServiceImpl;
import cn.shiwei.basic.util.PageList;
import cn.shiwei.org.domain.DictionariesType;
import cn.shiwei.org.mapper.DictionariesDetailMapper;
import cn.shiwei.org.mapper.DictionariesTypeMapper;
import cn.shiwei.org.service.IDictionariesTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DictionariesTypeServiceImpl extends BaseServiceImpl<DictionariesType> implements IDictionariesTypeService {

    @Autowired
    private DictionariesTypeMapper typeMapper;

    @Autowired
    private DictionariesDetailMapper detailMapper;

    /*private Integer queryTotal(){
        return typeMapper.queryTotal();
    }*/

    @Override
    public PageList<DictionariesType> queryDate(BaseQuery query) {
        Integer total = typeMapper.queryTotal();
        List<DictionariesType> data = typeMapper.queryDate(query);
        PageList<DictionariesType> pageList = new PageList<>(total ,data);
        return pageList;
    }

    @Override
    @Transactional
    public void remove(Long id) {
        detailMapper.removeByType(id);
        typeMapper.remove(id);
    }
}
